package com.futureCloudMOM.core.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.futureCloudMOM.common.constant.GenConstants;
import com.futureCloudMOM.core.entity.FBaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Length;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "Produce_TaskBillRoutingMaterial", description = "生产订单工艺工序用料清单")
@TableName(value = "Produce_TaskBillRoutingMaterial")
public class ProduceTaskBillRoutingMaterial extends FBaseEntity implements Serializable {



    @NotNull(message="[生产订单工艺工序ID]不能为空")
    @ApiModelProperty("生产订单工艺工序ID")
    @TableField(value = "taskBillRoutingProcessId")
    private Long taskBillRoutingProcessId;

    @NotNull(message="[物料ID]不能为空")
    @ApiModelProperty("物料ID")
    @TableField(value = "materialId")
    private Long materialId;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("备注")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "remark")
    private String remark;

    @NotBlank(message="[需求数量]不能为空")
    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("需求数量")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "hQty")
    private String hQty;

    @NotNull(message="[投入顺序]不能为空")
    @ApiModelProperty("投入顺序")
    @TableField(value = "subNo")
    private Long subNo;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("投入提前时间")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "leadtime")
    private String leadtime;

    @Size(max= 500,message="编码长度不能超过500")
    @ApiModelProperty("损失率")
    @Length(max= 500,message="编码长度不能超过500")
    @TableField(value = "lossRate")
    private String lossRate;

    @NotNull(message="[状态]不能为空")
    @ApiModelProperty("状态")
    @TableField(value = "status")
    private Long status;

    /**
     * 根据工艺工序物料获取实例
     *
     * @param routingMaterial 工艺工序物料
     * @return 实例
     */
    public static ProduceTaskBillRoutingMaterial getInstance(BasicRoutingMaterial routingMaterial) {
        String[] ignoreProperties = GenConstants.F_BASE_ENTITY;
        ProduceTaskBillRoutingMaterial taskBillRoutingMaterial = new ProduceTaskBillRoutingMaterial();
        BeanUtils.copyProperties(routingMaterial, taskBillRoutingMaterial, ignoreProperties);
        return taskBillRoutingMaterial;
    }



}

